home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Original Code / Lines Curves and Area Fills / DrawHouse / DrawHouse.cs next >
Encoding:
Text File  |  2001-01-15  |  1.2 KB  |  35 lines

  1. //----------------------------------------
  2. // DrawHouse.cs ⌐ 2001 by Charles Petzold
  3. //----------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Windows.Forms;
  7.  
  8. class DrawHouse: PrintableForm
  9. {
  10.      public new static void Main()
  11.      {
  12.           Application.Run(new DrawHouse());
  13.      }
  14.      public DrawHouse()
  15.      {
  16.           Text = "Draw a House in One Line";
  17.      }
  18.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  19.      {
  20.           grfx.DrawLines(new Pen(clr),
  21.                          new Point[] 
  22.                          {
  23.                          new Point(    cx / 4, 3 * cy / 4), // Lower left
  24.                          new Point(    cx / 4,     cy / 2),
  25.                          new Point(    cx / 2,     cy / 4), // Peak
  26.                          new Point(3 * cx / 4,     cy / 2),
  27.                          new Point(3 * cx / 4, 3 * cy / 4), // Lower right
  28.                          new Point(    cx / 4,     cy / 2),
  29.                          new Point(3 * cx / 4,     cy / 2),
  30.                          new Point(    cx / 4, 3 * cy / 4), // Lower left
  31.                          new Point(3 * cx / 4, 3 * cy / 4)  // Lower right
  32.                          });
  33.      }
  34. }
  35.